package com.soft.collateral.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.soft.collateral.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.Set;

public interface UserMapper extends BaseMapper<User> {

    /**
     * ${ew.customSqlSegment}:拼接where后的语句(在动态sq|中请勿处于标签内)
     * ${ew.sqlSelect} :拼接select SQL主体
     * ${ew.sqlSet} :拼接update主体
     * ${ew.sqlSegment} :拼接where后的语句
     */
    @Select("select * from users ${ew.customSqlSegment}")
    @Results({
            @Result(id = true , property = "id" , column = "id"),
            @Result(property = "role" , column = "id" , javaType = Set.class ,
                    many = @Many(select = "com.soft.collateral.mapper.RolesMapper.selectRolesByUserId"))
    })
    Page<User> selectAllPage(@Param("page") Page<User> page, @Param("ew") LambdaQueryWrapper<User> wrapper);
}